package com.example.ssm.d;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

// 在SayHello类中定义域name，方法hello()"hello,Tom!"
public class SayHello {
    private String name;

    public void setName(String name){
        this.name = name;
    }

    public void hello(){
        System.out.println("Hello," + this.name + "!");
    }
}


class Test{
    public static void main(String[] args) {
        //测试类中采用getBean的方式获取Sayhello的实例，调用hello()方法

        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        SayHello sayHello = (SayHello) applicationContext.getBean("sayHello");
        sayHello.hello();
    }
}